package com.osi.project.common.business;

import com.osi.start.common.business.dto.BaseDTO;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 数据库公共配置
 *
 * @author osi
 * @version 1.0 2019年9月5日 下午6:36:24
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
public class DbConfig extends BaseDTO {
	/** serialVersionUID*/
	private static final long serialVersionUID = 4787396438130656625L;
	private String type = "com.alibaba.druid.pool.DruidDataSource";
	private String driverClassName = "com.mysql.jdbc.Driver";
	private String url;
	private String username;
	private String password;
	
	private int initialSize = 5;//初始化大小
	private int minIdle = 5;//，最小
	private int maxActive = 50;//最大
	private long maxWait = 15000;//配置获取连接等待超时的时间
	private long timeBetweenEvictionRunsMillis = 60000L;//配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒
	private long minEvictableIdleTimeMillis = 300000L;//配置一个连接在池中最小生存的时间，单位是毫秒
	private String validationQuery = "SELECT 1";//验证连接是否有效。此参数必须设置为非空字符串，下面三项设置成true才能生
	private Boolean testWhileIdle = true;//指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
	private Boolean testOnBorrow = true;//指明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个
	private Boolean testOnReturn = false;//指明是否在归还到池中前进行检验
	private Boolean poolPreparedStatements = true;//打开PSCache，并且指定每个连接上PSCache的大小
	private int maxPoolPreparedStatementPerConnectionSize = 20;
	private String filters = "stat,wall,slf4j";//配置监控统计拦截的filters，去掉后监控界面sql无法统计，'wall'用于防火墙
	private String connectionProperties = "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000;druid.stat.logSlowSql=true";//通过connectProperties属性来打开mergeSql功能；慢SQL记录
	private String druidLoginUsername = "admin";
	private String druidLoginPwd = "osi123456";


}